package oop.lab.console.command;

import java.util.List;

import oop.lab.console.gameview.GomokuGameView;
import oop.lab.console.gameview.PeaceGameView;
import oop.lab.console.gameview.ReversiGameView;
import oop.lab.console.playground.PlayGround;
import oop.lab.domain.board.Board;
import oop.lab.domain.board.PieceColor;
import oop.lab.domain.game.GomokuGame;
import oop.lab.domain.game.PeaceGame;
import oop.lab.domain.game.ReversiGame;

public class NewGameCommand implements Command {
    List<String> commands = List.of("peace", "gomoku", "reversi");
    private final PlayGround session;

    public NewGameCommand(PlayGround session) {
        this.session = session;
    }

    @Override
    public void execute(String cmd) {
        if (cmd.equals("peace")) {
            session.addGame(new PeaceGameView(new PeaceGame()));
        } else if (cmd.equals("gomoku")) {
            session.addGame(new GomokuGameView(new GomokuGame()));
        } else if (cmd.equals("reversi")) {
            session.addGame(new ReversiGameView(new ReversiGame()));
        } else {
            throw new RuntimeException("Invalid command");
        }
    }

    @Override
    public boolean canAccept(String input) {
        return commands.contains(input);
    }

    @Override
    public String prompt() {
        return String.format("新游戏(%s)", String.join("/", commands));
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
